package sf.database.template.enjoy.ext;

import com.jfinal.template.Directive;
import com.jfinal.template.Env;
import com.jfinal.template.io.CharWriter;
import com.jfinal.template.io.FastStringWriter;
import com.jfinal.template.io.Writer;
import com.jfinal.template.stat.Scope;
import sf.database.template.enjoy.EnjoyHelp;

public class ReplaceSpaceDirective extends Directive {
    @Override
    public void exec(Env env, Scope scope, Writer writer) {
        CharWriter charWriter = new CharWriter(64);
        FastStringWriter fsw = new FastStringWriter();
        charWriter.init(fsw);
        try {
            stat.exec(env, scope, charWriter);
        } finally {
            charWriter.close();
        }
        String str = EnjoyHelp.deleteCRLFOnce(fsw.toString());
        write(writer, str);
    }

    public boolean hasEnd() {
        return true;
    }
}
